#!/usr/bin/env python3
"""
APIViewer 后端服务器启动脚本
"""
import uvicorn
import os
import sys

# 确保当前目录在Python路径中
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

if __name__ == "__main__":
    # 检查是否安装了依赖
    try:
        import fastapi
        import sqlalchemy
        import passlib
        import jose
    except ImportError as e:
        print(f"❌ 缺少依赖: {e}")
        print("请先安装依赖: pip install -r requirements.txt")
        sys.exit(1)
    
    print("🚀 启动 APIViewer 后端服务器...")
    print("📍 服务器地址: http://localhost:8000")
    print("📚 API文档: http://localhost:8000/docs")
    print("🛑 按 Ctrl+C 停止服务器")
    print("-" * 50)
    
    # 启动服务器
    uvicorn.run(
        "main:app",
        host="0.0.0.0",
        port=8000,
        reload=True,
        reload_dirs=["./"],
        log_level="info"
    ) 